﻿@model Lottery.Models.Home.AdvOrderReportModel
@{
    ViewBag.Title = "会员系统 - 高级单据统计";
    Model.Caption = "高级单据统计";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnConfirm").click(function () {
                $('form').submit();
            }
        );

        $("#date").ligerDateEditor({ showTime: false, label: '日期', initValue: '@Model.Date.ToString("yyyy-MM-dd")', format: "yyyy-MM-dd" });

        state4();
    });
    function state4() {
        $(".s4d").attr("disabled", $(".s4").attr("checked") == "checked");
    }
</script>
@using (Html.BeginForm())
{ 
    <div class="system_input_contain">
        <div class="input-text">
            @Html.TextBox("Date", Model.Date, new { @id = "date" })
            @Html.ValidationMessageFor(m => m.Date, new { style = "color:Red" })
        </div>
        <div class="input-text">
            @Html.CheckBoxFor(m => m.IsAll, new { onclick = "state4()", @class = "s4" })
            @Html.LabelFor(m => m.IsAll)
            @Html.DropDownListFor(m => m.User, new SelectList(Model.UserList), new { @class = "s4d" })
        </div>
        <div class="input-text">
            <input type="button" id="btnConfirm" value="统计" />
        </div>
    </div>
}
@if (Model.HasSearch)
{
    if (Model.List.Count == 0)
    { 
        <h2>没有你所需要统计的数据</h2>
    }
    else
    { 

    <script type="text/javascript">
    @{
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.AppendLine(string.Format("var data={{Total:{0},", Model.List.Count));
        sb.AppendLine("Rows:[");
        for (int i = 0; i < Model.List.Count; i++)
        {
            var item = Model.List[i];
            if (i == 0)
            {
                sb.Append("{");
            }
            else
            {
                sb.Append(",{");
            }
            sb.Append(string.Format("User:'{0}',", item.User));
            sb.Append(string.Format("Product:'{0}',", item.Product));
            sb.Append(string.Format("Money:'{0}'", item.Money));
            sb.Append("}");
        }
        sb.AppendLine("]};");
        
    }
    @Html.Raw(sb.ToString());

    var grid;
    $(function () {

        grid = $("#maingrid").ligerGrid({
            columns: [
                { display: '用户', name: 'User',width:100},
                { display: '产品', name: 'Product',width:100},
                { display: '金额', name: 'Money',width:100}],
                isScroll: false, data: data,pageSize:30,alternatingRow:true
        }
        );
        resetGridHeight(grid);
            $(window).resize(function () {
                resetGridHeight(grid);
            });
    });</script>

 <div id="maingrid"></div>
    }
}